package com.example.smartrefreshlayoutdemo.activity.practice;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.example.smartrefreshlayoutdemo.R;
import com.example.smartrefreshlayoutdemo.utils.StatusBarUtil;

import ezy.ui.layout.LoadingLayout;

public class QQBrowserPracticeActivity extends AppCompatActivity {
    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_practice_qqbrowser);

        final Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        final LoadingLayout loading = findViewById(R.id.loading);
        WebView webView = findViewById(R.id.webView);
        webView.loadUrl("https://www.oschina.net/news/131577/lg-says-it-will-license-webos-to-other-tv-mak");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                loading.showContent();
            }
        });

        StatusBarUtil.immersive(this);
        StatusBarUtil.setPaddingSmart(this,toolbar);
    }
}
